//
//  API.m
//  OAProject
//
//  Created by yhj on 2017/2/21.
//  Copyright © 2017年 cdnunion. All rights reserved.
//

#import "API.h"
#import "HttpClient.h"
#import "AppDelegate.h"


@implementation API

+(void)showMessage:(NSString *)message
{
    // 获取app的窗口  [UIApplication sharedApplication].keyWindow
    [[UIApplication sharedApplication].keyWindow makeToast:message duration:kGapTime position:CSToastPositionCenter];
}

// 用户登录
+(void)loginWithUserName:(NSString *)userName password:(NSString *)password success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(userName);
    NSParameterAssert(password);

    NSDictionary *params=@{
                        @"admin_name":userName,
                        @"code":password
                        };
   [[HttpClient shareClient] requestPath:@"admin/index/login" method:kPOST parameters:[params configParameters] success:^(NSURLSessionTask *operation, id responseObject) {
       
       // 登录成功提示
       [self showMessage:responseObject[@"error"]];

       if (success) {
           success(responseObject);
       }

   } failure:^(NSURLSessionTask *operation, NSError *error) {

   }];
}


// 添加项目
+(void)AddProjectWithProjectName:(NSString *)projectName description:(NSString *)description success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(projectName);

    NSDictionary *params=@{
                           @"project_name":projectName,
                           @"description":description
                           };

    NSLog(@"sdhfdhfd8778---%@",[params configParametersAdd]);
    
    [[HttpClient shareClient] requestPath:@"user/task/project" method:kPOST parameters:[params configParametersAdd] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

    }];
}

// 项目信息修改
+(void)EditProjectWithProjectID:(NSString *)projectID description:(NSString *)description success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(projectID);

    NSDictionary *params=@{
                           @"project_id":projectID,
                           @"description":description
                           };

    [[HttpClient shareClient] requestPath:@"user/task/project" method:kPOST parameters:[params configParametersEdit] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}


// 删除项目
+(void)DeleteProjectWithProjectID:(NSString *)projectID success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(projectID);

    NSDictionary *params=@{
                           @"project_id":projectID
                           };
    [[HttpClient shareClient] requestPath:@"user/task/project" method:kPOST parameters:[params configParametersDel] success:^(NSURLSessionTask *operation, id responseObject) {

        [self showMessage:@"删除成功"];

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

    }];
}

// 添加目标归类
+(void)AddSortWithSortName:(NSString *)sortName memo:(NSString *)memo success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(sortName);

    NSDictionary *params=@{
                           @"target_name":sortName,
                           @"memo":memo
                           };

    [[HttpClient shareClient] requestPath:@"user/task/target_type" method:kPOST parameters:[params configParametersAdd] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 修改目标归类
+(void)EdidSortWithSortID:(NSString *)sortID sortName:(NSString *)sortName memo:(NSString *)memo success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(sortID);

    NSDictionary *params=@{
                           @"target_type_id":sortID,
                           @"target_name":sortName,
                           @"memo":memo
                           };

    [[HttpClient shareClient] requestPath:@"user/task/target_type" method:kPOST parameters:[params configParametersEdit] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}


// 删除目标归类
+(void)DeleteSortWithSortID:(NSString *)sortID success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(sortID);

    NSDictionary *params=@{
                           @"target_type_id":sortID
                           };

    [[HttpClient shareClient] requestPath:@"user/task/target_type" method:kPOST parameters:[params configParametersDel] success:^(NSURLSessionTask *operation, id responseObject) {

        [self showMessage:@"删除成功"];

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}


// 获取项目列表
+(void)GetProjectListWithPer_page:(NSString *)per_page page_num:(NSString *)page_num success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSDictionary *params=@{
                           @"per_page":per_page,
                           @"page_num":page_num
                           };

    NSLog(@"sdjhfd6660--%@",[params configParametersRows]);

    [[HttpClient shareClient] requestPath:@"user/task/project" method:kPOST parameters:[params configParametersRows] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

        NSHTTPURLResponse *httpResponse=(NSHTTPURLResponse *)operation.response;
        NSInteger stateCode=[httpResponse statusCode];

        NSData *errorData=[[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
        id jsonObject=[NSJSONSerialization JSONObjectWithData:errorData options:NSJSONReadingMutableLeaves error:nil];

        [self showMessage:jsonObject[@"error"]];

        if (failure) {
            failure(stateCode);
        }
    }];
}

// 获取目标归类列表
+(void)GetSortListWithPer_page:(NSString *)per_page page_num:(NSString *)page_num success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSDictionary *params=@{
                           @"per_page":per_page,
                           @"page_num":page_num
                           };

    [[HttpClient shareClient] requestPath:@"user/task/target_type" method:kPOST parameters:[params configParametersRows] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 添加用户
+(void)AddUserWithName:(NSString *)name phone:(NSString *)phone memberID:(NSString *)memberID email:(NSString *)email passwd:(NSString *)passwd success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(name);
    NSParameterAssert(memberID);
    NSParameterAssert(email);
    NSParameterAssert(passwd);
    NSParameterAssert(phone);

    NSDictionary *params=@{
                           @"name":name,
                           @"mobile":phone,
                           @"member_id":memberID,
                           @"email":email,
                           @"passwd":passwd
                           };

    [[HttpClient shareClient] requestPath:@"user/user/index" method:kPOST parameters:[params configParametersAdd] success:^(NSURLSessionTask *operation, id responseObject) {

        [self showMessage:@"添加成功"];

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];

}

// 获取所有的用户列表
+(void)GetAllUserListWithPer_page:(NSString *)per_page page_num:(NSString *)page_num success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSDictionary *params=@{
                           @"per_page":per_page,
                           @"page_num":page_num
                           };

    [[HttpClient shareClient] requestPath:@"user/user/index" method:kPOST parameters:[params configParametersRows] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 获取优先级
+(void)GetPriorityListSuccess:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSDictionary *params=@{ };

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersPriority] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

    }];
}

// 获取部门
+(void)GetGroupListWithGroupID:(NSString *)groupID success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(groupID);

    NSDictionary *params=@{
                           @"group_id":groupID
                           };

    [[HttpClient shareClient] requestPath:@"user/user/group" method:kPOST parameters:[params configParametersLevel_Rows] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 获取下级部门及其用户列表
+(void)GetGroupDetailListWithGroupID:(NSString *)groupID return_type:(NSString *)return_type success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSDictionary *params=@{
                           @"group_id":groupID,
                           @"return_type":return_type
                           };

    [[HttpClient shareClient] requestPath:@"user/user/group" method:kPOST parameters:[params configParametersLevel_Users] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 获取流程列表
+(void)GetTaskProgressListWithTaskID:(NSString *)taskID success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(taskID);

    NSDictionary *params=@{
                           @"task_id":taskID
                           };
    NSLog(@"sghghdgh9---%@",[params configParametersRows]);

    [[HttpClient shareClient] requestPath:@"user/task/flow" method:kPOST parameters:[params configParametersRows] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

    }];
}

// 获取任务状态列表
+(void)GetTaskStatusListSuccess:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSDictionary *params=@{ };

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersStatus] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 获取流程状态列表
+(void)GetTaskProgressStatusListSuccess:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSDictionary *params=@{ };

    [[HttpClient shareClient] requestPath:@"user/task/flow" method:kPOST parameters:[params configParametersStatus] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 获取任务日志列表
+(void)GetTaskLogListWithTaskID:(NSString *)taskID stepID:(NSString *)stepID per_page:(NSString *)per_page page_num:(NSString *)page_num success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(taskID);

    NSDictionary *params=@{
                           @"task_id":taskID,
                           @"step_id":stepID,
                           @"per_page":per_page,
                           @"page_num":page_num
                           };

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersLogs] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

        NSHTTPURLResponse *httpResponse=(NSHTTPURLResponse *)operation.response;
        NSInteger stateCode=[httpResponse statusCode];

        NSData *errorData=[[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
        id jsonObject=[NSJSONSerialization JSONObjectWithData:errorData options:NSJSONReadingMutableLeaves error:nil];

        [self showMessage:jsonObject[@"error"]];

        if (failure) {
            failure(stateCode);
        }
    }];
}

// 获取流程详情
+(void)GetTaskProgressDetailWithStepID:(NSString *)stepID success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(stepID);

    NSDictionary *params=@{
                           @"step_id":stepID
                           };

    [[HttpClient shareClient] requestPath:@"user/task/flow" method:kPOST parameters:[params configParametersRow] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 获取任务详情
+(void)GetTaskDetailWithTaskID:(NSString *)taskID success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(taskID);

    NSDictionary *params=@{
                           @"task_id":taskID
                           };

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersRow] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 任务状态更新
+(void)UpdateTaskStatusWithTaskID:(NSString *)taskID tempo:(NSString *)tempo log:(NSString *)log attachments:(NSString *)attachments success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
//    NSParameterAssert(taskID);
//    NSParameterAssert(tempo);

    NSDictionary *params=@{
                           @"task_id":taskID,
                           @"tempo":tempo,
                           @"log":log,
                           @"attachments":attachments
                           };

    NSLog(@"sd9f9fddfj---%@",[params configParametersRefresh]);
    
    [[HttpClient shareClient] requestPath:@"user/task/flow" method:kPOST parameters:[params configParametersRefresh] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

        NSHTTPURLResponse *httpResponse=(NSHTTPURLResponse *)operation.response;
        NSInteger stateCode=[httpResponse statusCode];

        NSData *errorData=[[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
        id jsonObject=[NSJSONSerialization JSONObjectWithData:errorData options:NSJSONReadingMutableLeaves error:nil];

        [self showMessage:jsonObject[@"error"]];

        if (failure) {
            failure(stateCode);
        }

        NSLog(@"sdjdsjjdfjfd----%@  0-----%@",error,jsonObject[@"error"]);
        
    }];
}

// 执行人流程处理
+(void)DealTaskWithTaskID:(NSString *)taskID ac:(NSString *)ac turnID:(NSString *)turnID  memo:(NSString *)memo success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure;
{
    NSParameterAssert(taskID);
    NSParameterAssert(ac);
    NSParameterAssert(turnID);

    NSDictionary *params=@{
                           @"task_id":taskID,
                           @"ac":ac,
                           @"turn_id":turnID
                           };

    NSLog(@"sdghsdghdshg6660---%@",[params configParametersDeal]);

    [[HttpClient shareClient] requestPath:@"user/task/flow" method:kPOST parameters:[params configParametersDeal] success:^(NSURLSessionTask *operation, id responseObject) {

        NSLog(@"sadsdgsdhg666223---%@",responseObject);
        
        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

        NSLog(@"sdhjsdhhfds666---%@",error);

    }];
}

// 获取任务列表
+(void)GetTaskListWithProjectID:(NSString *)projectID createrID:(NSString *)createrID userID:(NSString *)userID  targetType:(NSString *)targetType priority:(NSString *)priority status:(NSString *)status stepStatus:(NSString *)stepStatus per_page:(NSString *)per_page page_num:(NSString *)page_num success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSDictionary *params=@{
                           @"project_id":projectID,
                           @"creater_id":createrID,
                           @"user_id":userID,
                           @"target_type":targetType,
                           @"priority":priority,
                           @"status":status,
                           @"step_status":stepStatus,
                           @"per_page":per_page,
                           @"page_num":page_num
                           };

    NSLog(@"sdjsdjhdshdh888---%@",[params configParametersRows]);

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersRows] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

        NSLog(@"-0---%@",error);

        NSHTTPURLResponse *httpResponse=(NSHTTPURLResponse *)operation.response;
        NSInteger stateCode=[httpResponse statusCode];

        NSData *errorData=[[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
        id jsonObject=[NSJSONSerialization JSONObjectWithData:errorData options:NSJSONReadingMutableLeaves error:nil];

        [self showMessage:jsonObject[@"error"]];

        if (failure) {
            failure(stateCode);
        }

        NSLog(@"sdjdsjjdfjfd22222----%@  aaa0-----%@",error,jsonObject[@"error"]);

    }];
}


// 添加流程
+(void)AddTaskProgressWithTaskID:(NSString *)taskID title:(NSString *)title user_ids:(NSArray *)user_ids estimateEtime:(NSString *)estimateEtime fatherID:(NSString *)fatherID remindMin:(NSString *)remindMin description:(NSString *)description attachments:(NSString *)attachments success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(taskID);
    NSParameterAssert(title);
    NSParameterAssert(user_ids);
    NSParameterAssert(estimateEtime);
    NSParameterAssert(fatherID);

    NSDictionary *params=@{
                           @"task_id":taskID,
                           @"title":title,
                           @"user_ids":user_ids,
                           @"estimate_etime":estimateEtime,
                           @"father_id":fatherID,
                           @"remind_min":remindMin,
                           @"description":description,
                           @"attachments":attachments
                           };

    NSLog(@"shjdfhjfdhj77---%@",params);

    NSLog(@"ahjdshds99---%@",[params configParametersAdd]);

    [[HttpClient shareClient] requestPath:@"user/task/flow" method:kPOST parameters:[params configParametersAdd] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 修改流程
+(void)EditTaskProgressWithStepID:(NSString *)stepID title:(NSString *)title userIDs:(NSMutableArray *)userIDs estimateEtime:(NSString *)estimateEtime fatherID:(NSString *)fatherID remindMin:(NSString *)remindMin description:(NSString *)description attachments:(NSString *)attachments success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(stepID);

    NSDictionary *params=@{
                           @"step_id":stepID,
                           @"title":title,
                           @"user_ids":userIDs,
                           @"estimate_etime":estimateEtime,
                           @"father_id":fatherID,
                           @"remind_min":remindMin,
                           @"description":description,
                           @"attachments":attachments
                           };

    NSLog(@"sdhjdsh66677---%@",params);

    NSLog(@"sdghdsgds66600---%@",[params configParametersEdit]);
    
    [[HttpClient shareClient] requestPath:@"user/task/flow" method:kPOST parameters:[params configParametersEdit] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}


// 删除流程
+(void)DeleteTaskProgressWithStepID:(NSString *)stepID success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(stepID);

    NSDictionary *params=@{
                           @"step_id":stepID
                           };

    NSLog(@"sdsdhjds---%@",[params configParametersDelete]);
    
    [[HttpClient shareClient] requestPath:@"user/task/flow" method:kPOST parameters:[params configParametersDelete] success:^(NSURLSessionTask *operation, id responseObject) {

//         [self showMessage:@"删除成功"];

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 取消任务
+(void)CancelTaskWithTaskID:(NSString *)taskID success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(taskID);

    NSDictionary *params=@{
                           @"task_id":taskID
                           };

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersCancel] success:^(NSURLSessionTask *operation, id responseObject) {

//        if ([responseObject[@"rt"] isEqual:@(1)])
//        {
////            [self showMessage:@"取消任务成功"];
//        }
//        else
//        {
//            [self showMessage:responseObject[@"error"]];
//        }

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}


// 添加任务
+(void)AddTaskSuccess:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSDictionary *params=@{ };

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersAdd] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

    }];
}


// 注销
+(void)logoutWithSuccess:(void(^)(BOOL is_logout))success failure:(void(^)(NSInteger stateCode))failure
{
    NSDictionary *params=@{
                           @"token":[Util getUserDefaultObjectForKey:@"Token"]
                           };

    [[HttpClient shareClient] requestPath:@"admin/index/logout" method:kPOST parameters:params success:^(NSURLSessionTask *operation, id responseObject) {
        
       [self showMessage:@"退出成功"];

        if (success) {
            success(YES);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

        NSHTTPURLResponse *httpResponse=(NSHTTPURLResponse *)operation.response;
        NSInteger stateCode=[httpResponse statusCode];
        NSData *errorData=[[error userInfo] objectForKey:@"com.alamofire.serialization.response.error.data"];
        id jsonObject=[NSJSONSerialization JSONObjectWithData:errorData options:NSJSONReadingMutableLeaves error:nil];

        [self showMessage:jsonObject[@"error"]];

        if (failure) {
            failure(stateCode);
        }
    }];
}

// 发布任务
+(void)PublicTaskWithTaskID:(NSString *)taskID projectID:(NSString *)projectID title:(NSString *)title  target_types:(NSArray *)target_types priority:(NSString *)priority estimate_stime:(NSString *)estimate_stime target_desc:(NSString *)target_desc exec_method:(NSString *)exec_method memo:(NSString *)memo attachments:(NSMutableDictionary *)attachments success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(taskID);
    NSParameterAssert(projectID);
    NSParameterAssert(title);
    NSParameterAssert(target_types);
    NSParameterAssert(priority);
    NSParameterAssert(estimate_stime);
    NSParameterAssert(target_desc);
    NSParameterAssert(exec_method);

    NSDictionary *params=@{
                           @"task_id":taskID,
                           @"project_id":projectID,
                           @"title":title,
                           @"target_types":target_types,
                           @"priority":priority,
                           @"estimate_stime":estimate_stime,
                           @"target_desc":target_desc,
                           @"exec_method":exec_method,
                           @"memo":memo,
                           @"attachments":attachments
                           };

    NSLog(@"sdhgbhfd888---%@",[params configParametersPublish]);

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersPublish] success:^(NSURLSessionTask *operation, id responseObject) {

        NSLog(@"sgdhgdfgfd0099--%@  ---%@",responseObject,responseObject[@"error"]);

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

        
    }];
}

// 修改任务
+(void)EditTaskWithTaskID:(NSString *)taskID projectID:(NSString *)projectID title:(NSString *)title target_types:(NSArray *)target_types priority:(NSString *)priority estimate_stime:(NSString *)estimate_stime target_desc:(NSString *)target_desc exec_method:(NSString *)exec_method memo:(NSString *)memo attachments:(NSMutableDictionary *)attachments success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(taskID);
    NSParameterAssert(projectID);
    NSParameterAssert(title);
    NSParameterAssert(target_types);
    NSParameterAssert(priority);
    NSParameterAssert(estimate_stime);
    NSParameterAssert(target_desc);
    NSParameterAssert(exec_method);

    NSDictionary *params=@{
                           @"task_id":taskID,
                           @"project_id":projectID,
                           @"title":title,
                           @"target_types":target_types,
                           @"priority":priority,
                           @"estimate_stime":estimate_stime,
                           @"target_desc":target_desc,
                           @"exec_method":exec_method,
                           @"memo":memo,
                           @"attachments":attachments
                           };

    NSLog(@"sdhhdshds55599---%@",[params configParametersEdit]);

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersEdit] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

    }];
}


// 任务验收
+(void)CheckTaskID:(NSString *)taskID ac:(NSString *)ac turn_id:(NSString *)turn_id memo:(NSString *)memo success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(ac);
    NSParameterAssert(taskID);

    NSDictionary *params=@{
                           @"task_id":taskID,
                           @"ac":ac,
                           @"turn_id":turn_id,
                           @"memo":memo
                           };

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersAcceptance] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}


// 任务评分
+(void)EvaluateTaskWithTaskID:(NSString *)taskID quality:(NSString *)quality efficient:(NSString *)efficient attitude:(NSString *)attitude memo:(NSString *)memo step_evaluate:(NSArray *)step_evaluate success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(taskID);
    NSParameterAssert(quality);
    NSParameterAssert(efficient);
    NSParameterAssert(attitude);

    NSDictionary *params=@{
                           @"task_id":taskID,
                           @"quality":quality,
                           @"efficient":efficient,
                           @"attitude":attitude,
                           @"memo":memo,
                           @"step_evaluate":step_evaluate
                           };

    NSLog(@"sdhhdshsd---%@",[params configParametersEvaluate]);

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersEvaluate] success:^(NSURLSessionTask *operation, id responseObject) {

        //        [self showMessage:@"任务发布成功"];

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 获取评价信息
+(void)GetTaskEvaluateInfoRefID:(NSString *)refID ref:(NSString *)ref success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(refID);
    NSParameterAssert(ref);

    NSDictionary *params=@{
                           @"ref_id":refID,
                           @"ref":ref
                           };

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersGetScore] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
    }];
}

// 更新app
+(void)updateAppWithMyIDCode:(NSString *)myIDCode token:(NSString *)token success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(myIDCode);
    NSParameterAssert(token);

    NSDictionary *params=@{
//                           @"member_id":memberID,
                           @"MYIDCODE":myIDCode,
                           @"token":token
                           };

    NSLog(@"sdjsdhjfdfdh0---%@",params);

    [[HttpClient shareClient] requestPath:@"admin/index/upload_token" method:kPOST parameters:params success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {

        NSLog(@"jkjfdjfsj---%@",error);

    }];
}

// 获取任务日志数据
+(void)GetTaskLogDetailWithLogID:(NSString *)logID success:(void(^)(id res))success failure:(void(^)(NSInteger stateCode))failure
{
    NSParameterAssert(logID);

    NSDictionary *params=@{
                           @"log_id":logID
                           };

    NSLog(@"sdjsdhjfdfdh0---%@",[params configParametersLog]);

    [[HttpClient shareClient] requestPath:@"user/task/index" method:kPOST parameters:[params configParametersLog] success:^(NSURLSessionTask *operation, id responseObject) {

        if (success) {
            success(responseObject);
        }

    } failure:^(NSURLSessionTask *operation, NSError *error) {
        
        NSLog(@"jkjfdjfsj---%@",error);
        
    }];
}

@end
